class GUIGraph

This is the holder GUI widget for images. It's main purpose is to work around some of the bugs in the Ruby Gtk implementation of Gtk::Image. Would be nice to inherit from Gtk::Image but the implementation is buggy and throws exceptions when the constructor is not given a Gdk::Pixbuf.

Attributes

epoch[R]

Public Class Methods

new() click to toggle source

Initialize an empty container with the current epoch set to 0.

Calls superclass method
# File lib/gui_graph.rb, line 14
def initialize
  super
  @epoch = 0
end

Public Instance Methods

show_graph(graph_file, epoch) click to toggle source

Displays the image specified by the file at 'graph_file'. The current image is only updated if the epoch passed here is different from the last time it was called.

# File lib/gui_graph.rb, line 22
def show_graph(graph_file, epoch)
  return if @epoch == epoch

  @epoch = epoch
  begin
    graph_image = Gdk::Pixbuf.new(graph_file)
  rescue IOError => e
    puts e
    puts "Cannot load image!"
    exit
  end

  # Gtk::Image seems very buggy. Have to be careful with it
  if not @image.nil?
    remove(@image)
    @image.destroy
  end
  @image = Gtk::Image.new(graph_image)
  add(@image)

  show_all
end